//
//  NSDictionary+Additions.m
//  OrderSeat
//
//  Created by wangwei on 13-10-22.
//  Copyright (c) 2013年 wangwei. All rights reserved.
//

#import "NSDictionary+Additions.h"

@implementation NSDictionary (Additions)

+(NSDictionary*)dictionaryWithContentsOfJSONURLString:(NSString*)urlAddress {
    NSData* data =[NSData dataWithContentsOfURL:[NSURL URLWithString: urlAddress]];
    __autoreleasing NSError* error =nil;
    id result =[NSJSONSerialization JSONObjectWithData:data
                                               options:kNilOptions error:&error];
    if(error != nil)return nil;
    return result;
}

-(NSData*)toJSON {
    NSError* error =nil;
    id result =[NSJSONSerialization dataWithJSONObject:self
                                               options:kNilOptions error:&error];
    if(error !=nil)return nil;
    return result;
}

@end
